import Vue from 'vue'
import VueRouter from 'vue-router'
import LoginView from '../views/LoginView/LoginView'
import LayOut from '@/views/LayOut/LayOut'

Vue.use(VueRouter)

const routes = [{
        path: '/',
        // 重定向到登录页
        redirect: '/loginview'
    },
    {
        path: '/loginview',
        name: 'loginview',
        component: LoginView
    },
    {
        path: '/admin',
        component: LayOut,

        // 可以设置/也可以不设置
        children: [{
                path: '/',
                redirect: 'welcome'
            },
            {
                // path: '/admin/welcome',
                path: 'welcome',
                component: () =>
                    import ('@/views/LayOut/WelcomeView.vue')
            }, {
                path: 'userlist',
                component: () =>
                    import ('@/views/UserView/UserList.vue')
            }, {
                path: 'useradd',
                component: () =>
                    import ('@/views/UserView/UserAdd.vue')
            }, {
                path: 'productcate',
                component: () =>
                    import ('@/views/ProductView/ProductCate.vue')
            }, {
                path: 'productcateadd',
                component: () =>
                    import ('@/views/ProductView/ProductCateAdd.vue')
            }
        ]
    }
]

const router = new VueRouter({
    routes
})

export default router